load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
    name = "optfmt_lib",
    srcs = ["main.go"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/opt/optgen/cmd/optfmt",
    visibility = ["//visibility:private"],
    deps = [
        "//pkg/sql/opt/optgen/lang",
        "//pkg/util/pretty",
        "@com_github_pmezard_go_difflib//difflib",
    ],
)

go_binary(
    name = "optfmt",
    embed = [":optfmt_lib"],
    visibility = ["//visibility:public"],
)

go_test(
    name = "optfmt_test",
    size = "small",
    srcs = ["main_test.go"],
    data = glob(["testdata/**"]),
    embed = [":optfmt_lib"],
    deps = [
        "//pkg/testutils/datapathutils",
        "@com_github_cockroachdb_datadriven//:datadriven",
    ],
)
